#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn],dp[maxn][2];
long long maxAlternatingSum(vector<int>& nums) {
    int n=nums.size();
    for(int i=0;i<nums.size();i++)
    {
        a[i+1]=nums[i];
    }
    LL mx1=0;LL mx0=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=mx1-a[i];

        dp[i][1]=mx0+a[i];

        mx1=max(mx1,dp[i][1]);
        mx0=max(mx0,dp[i][0]);
    }
    LL ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,max(dp[i][0],dp[i][1]));
    return ans;
}
int main(void){
    vector<int>nums;
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        nums.push_back(x);
    }
    cout<<maxAlternatingSum(nums)<<endl;
   	return 0;
}
